import { Router, Redirect, Route, Switch } from 'react-router-dom'
import Login from '@/pages/Login'
import Layout from '@/pages/Layout'
import NotFound from '@/pages/NotFound'
import ProfileEdit from '@/pages/Profile/Edit'
import { PrivateRoute } from './components/PrivateRoute'
import history from './utils/history'
import Chat from './pages/Chat'
function App() {
  return (
    <Router history={history}>
      <div className='app'>
        <Switch>
          {/* 重定向 redirect */}
          {/*  <Redirect exact from='/' to='/home'></Redirect> */}
          <Route exact path='/' render={() => <Redirect to='/home'></Redirect>}></Route>
          <Route path='/login'>
            <Login></Login>
          </Route>
          <Route path='/home'>
            <Layout></Layout>
          </Route>
          <PrivateRoute path='/profile/edit'>
            <ProfileEdit></ProfileEdit>
          </PrivateRoute>
          <PrivateRoute path='/chat'>
            <Chat></Chat>
          </PrivateRoute>

          <Route>
            <NotFound></NotFound>
          </Route>
        </Switch>
      </div>
    </Router>
  )
}

export default App
